<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:f="http://java.sun.com/jsf/core">

    <ui:composition template="layout.xhtml">
        <ui:define name="body">
            <div class="section">
                <h1>Minhas Reservas</h1>                

                <h:form id="formReserve">
                    <div style="width: 100%; text-align: right">
                    <p:button value="Reservar Lote" style="margin-bottom: 15px;" icon="ui-icon-tag" href="reserve.xhtml" />
                    </div>
                    <p:growl id="msg" life="3000"/>
                    <div class="container_24 clearfix">

                        <p:dataTable id="tableReserves" var="r" value="#{managerIndexReserve.myReserves()}" 
                                     styleClass="grid_24"
                                     rowIndexVar="rowid"
                                     rows="20" paginator="true"  
                                     paginatorPosition="bottom"
                                     emptyMessage="Nenhum registro">  
                            <f:facet name="header">
                                Reservas
                            </f:facet>
                            <p:column headerText="Empreendimento" styleClass="#{r.expired ? 'ui-state-disabled' : ''}" >  
                                <h:outputText  value="#{r.lot.enterprise.name}"/>
                            </p:column>  
                            <p:column headerText="Bloco - Número" styleClass="#{r.expired ? 'ui-state-disabled' : ''}">  
                                <h:outputText value="Bloco: #{r.lot.block} - Número: #{r.lot.num}"/>
                            </p:column>
                             <p:column headerText="Expiração" styleClass="#{r.expired ? 'ui-state-disabled' : ''}" >  
                                 <h:outputText value="#{r.expiresAt}">
                                    <f:convertDateTime locale="pt_BR" pattern="dd/MM/yyyy - HH:mm"/>  
                                </h:outputText>
                            </p:column>
                            <p:column headerText="Já Expirou ?" style="text-align: center" styleClass="#{r.expired ? 'ui-state-disabled' : ''}">  
                                 <h:outputText value="#{r.expired ? 'Sim' : 'Não'}" />
                            </p:column>
                            <p:column headerText="Ação" width="75" style="text-align: center" styleClass="#{r.expired ? 'ui-state-disabled' : ''}">
                                <p:button  style="width: 20px; height: 20px;" 
                                           update="@form" title="Comprar Lote"
                                           rendered="#{!r.expired}"
                                           href="createsale.xhtml?lotId=#{r.lot.id}" 
                                           icon="ui-icon-document"/>

                            </p:column>
                        </p:dataTable> 
                             <div class="buttonAction" >
                                <p:button value="Voltar"
                                          href="indexcorrector.xhtml"
                                          icon="ui-icon-arrowreturnthick-1-w"/>
                            </div>

                    </div>
                </h:form>
            </div>
        </ui:define>
    </ui:composition>

</html>
